<template>
  <div>
    <ul>
      <li v-for="(value,name,index) in infoItem" :key="index">{{name}}---{{value}}</li>
    </ul>
    <!-- 找下标最方便  找对象中的唯一值 id-->
    <button @click="getId">加入购物车</button>
  </div>
</template>

<script>
export default {
  name: "InfoItem",
  props: ["infoItem"],
  data() {
    return {};
  },

  components: {},

  computed: {},

  beforeMount() {},

  mounted() {},

  methods: {
    getId() {
      console.log(this.infoItem.id);
      const item_id = this.infoItem.id;
      // 子传父  $emit
      this.$emit("get_item_id", item_id);
    }
  },

  watch: {}
};
</script>
<style lang='' scoped>
</style>